<!--
 * @Date: 2023-03-28 17:51:03
 * @LastEditTime: 2023-03-29 18:10:34
-->
<template>
  1232132
  <div id="box">
    <input type="text" />
    <button>阿斯蒂芬</button>
    <a-select
      class="langSelect"
      v-model:value="value"
      @change="handleChange"
      :options="options"
    >
    </a-select>
  </div>
</template>

<script>
export default {
  name: 'language_sdk',
};
</script>
<script setup>
import { getCurrentInstance, ref, onMounted, computed } from 'vue';
import { useCommonStore } from '../../src/store/index';

const instance = getCurrentInstance();
const { proxy } = instance;
const commonStore = useCommonStore();

onMounted(() => {
  value.value = commonStore.language;
  getData();
});

const options = [
  { value: 0, label: '中文' },
  { value: 1, label: 'English' },
];
const value = ref(0);
const handleChange = (e) => {
  localStorage.setItem('language', e);
  commonStore.SET_LANG(e);

  getData();
};

const getData = () => {
  const xhr = new XMLHttpRequest();
  const url = 'http://java.yhz.huikaoedu.com/api_Iflytek/expo-info/expoDetail';

  xhr.open('GET', url, false);
  xhr.send();

  let data;
  if (xhr.readyState == 4 && xhr.status == 200)
    data = JSON.parse(xhr.response).data;
  instance.appContext.config.globalProperties.langData = data;
};
</script>

<style lang="less" scoped>
.langSelect {
  width: 120px;
  position: absolute;
  right: 0;
  top: 0;
}
</style>
